<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>用户列表</title>
    <link rel="stylesheet" type="text/css" media="screen"
          href="${pageContext.request.contextPath}/resources/css/bootstrap.min.css">
</head>
<body>
<div class="container">
    <div class="row" style="margin-top: 40px">
        <div class="col-md-8 col-md-offset-2 ">
            <div class="panel panel-primary">
                <div class="panel-heading" style="display: flex; justify-content: space-between;align-items: center">
                    用户列表
                    <div class="">
                        <%--
                            ${pageContext.request.contextPath}是JSP中取得绝对路径的方法，等价于<%=request.getContextPath()%>
                            例如在浏览器中访问的路径为：http://localhost:8080/xmvc01/users/toAddUser
                            则使用${pageContext.request.contextPath}或<%=request.getContextPath()%>
                            取出来的值就是/users/toAddUser, 而 "/"代表的含义就是http://localhost:8080
                        --%>
                        <a class="btn btn-primary" href="${pageContext.request.contextPath}/users/toAddUser">添加用户</a>
                    </div>
                </div>
                <table class="table table-bordered table-hover text-center">
                    <thead>
                    <tr class="info">
                        <td>用户名称</td>
                        <td>用户密码</td>
                        <td>用户操作</td>
                    </tr>
                    </thead>
                    <tbody>
                    <c:forEach var="user" items="${userList}">
                        <tr>
                            <td>${user.userName}</td>
                            <td>${user.password}</td>
                            <td>
                                <a href="${pageContext.request.contextPath}/users/toUpdateUser?id=${user.id}">修改用户</a>
                                &nbsp;|&nbsp;
                                <a href="${pageContext.request.contextPath}/users/deleteUserById/${user.id}">删除用户</a>
                            </td>
                        </tr>
                    </c:forEach>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
</body>
</html>